﻿using JVMTI_CONN_CONNECT;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;

namespace JVMTI_CORE_SHELL
{
    public class PropertyBag
    {
        public string PropertyName { get; set; }
        public object Value { get; set; }
    }

    public class PropertyBagDsicoverableAttribue : Attribute { }

    public class PropertyBags : List<PropertyBag>
    {
        public static PropertyBags ConvertToPropertyBags(object o, bool isSearch = true)
        {
            var properties = o.GetType().GetProperties();
            PropertyBags bags = new PropertyBags();
            foreach (var property in properties)
            {
                if (property.Name == "HighlightingEvent" || property.Name == "StackTrace" || (property.Name == "Timestamp" && isSearch)) continue;
                if (!isSearch && property.GetValue(o, null) == null) continue;
                bags.Add(new PropertyBag() { PropertyName = property.Name, Value = property.GetValue(o, null) });
            }
            return bags;
        }
    }

}
